const children = [

];

const children_comment = [
    {
        path: "info/bfCircle/comment",
        name: "comment",
        component: () => import('@/views/book/detail/bfCircle/comment/comment.vue'),
    },
    {
        path: "info/bfCircle/discuss",
        name: "discuss",
        component: () => import('@/views/book/detail/bfCircle/discuss/discuss.vue'),
    }
]

const children_info = [
    {
        path: '/info/contents',
        name: 'contents',
        component: () => import('@/views/book/detail/contents/contents.vue'),
    },
    {
        path: '/info/intro',
        name: 'intro',
        component: () => import('@/views/book/detail/intro/intro.vue'),
    },
    {
        path: '/info/bfCircle',
        name: 'bfCircle',
        component: () => import('@/views/book/detail/bfCircle/bfCircle.vue'),
        children: children_comment
    }
];

const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/normal/login/login.vue')
    },
    {
        path: '/signup',
        name: 'SignUp',
        component: () => import('@/views/normal/login/signup.vue')
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/normal/home/home.vue'),
        children
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    },
    {
        path: '/info',
        name: "Details",
        component: () => import('@/views/book/detail/detail.vue'),
        children: children_info,
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

//本文件默认导出 routes 对象
export default routes;